
import sys
from copy import deepcopy
"""
4
1101
1011
1001
1111

6
101001
110100
111011
010101
111111
010100

4
1111
0101
1101
0010
"""

def get_zeros(N):
    zeros = []
    for idx in range(N):
        zeros.append([0]*N)
    return zeros


def get_connected_domain(data_matrix, pos, init_mask):
    init_mask[pos[0]][pos[1]] = 1
    # left
    if pos[0]>0 and data_matrix[pos[0]-1][pos[1]]==0 and init_mask[pos[0]-1][pos[1]]==0:
        init_mask = get_connected_domain(data_matrix, (pos[0]-1, pos[1]), init_mask)
    
    # right
    if pos[0]<len(data_matrix)-1 and data_matrix[pos[0]+1][pos[1]]==0 and init_mask[pos[0]+1][pos[1]]==0:
        init_mask = get_connected_domain(data_matrix, (pos[0]+1, pos[1]), init_mask)

    # up
    if pos[1]>0 and data_matrix[pos[0]][pos[1]-1]==0 and init_mask[pos[0]][pos[1]-1]==0:
        init_mask = get_connected_domain(data_matrix, (pos[0], pos[1]-1), init_mask)

    # down
    if pos[1]<len(data_matrix)-1 and data_matrix[pos[0]][pos[1]+1]==0 and init_mask[pos[0]][pos[1]+1]==0:
        init_mask = get_connected_domain(data_matrix, (pos[0], pos[1]+1), init_mask)
    return init_mask


def connected_domain(data_matrix):
    N = len(data_matrix)
    zeros = get_zeros(N)
    edge_connect_matrix_list = []
    # row 1
    for idx in range(N):
        if data_matrix[0][idx] == 0:
            connect_domain = get_connected_domain(data_matrix, (0,idx), deepcopy(zeros))
            edge_connect_matrix_list.append(connect_domain)
    for idx in range(N):
        if data_matrix[N-1][idx] == 0:
            connect_domain = get_connected_domain(data_matrix, (N-1,idx), deepcopy(zeros))
            edge_connect_matrix_list.append(connect_domain)
    if N > 2:
        for idx in range(N-2):
            if data_matrix[idx+1][0] == 0:
                connect_domain = get_connected_domain(data_matrix, (idx+1,0), deepcopy(zeros))
                edge_connect_matrix_list.append(connect_domain)
        for idx in range(N-2):
            if data_matrix[idx+1][N-1] == 0:
                connect_domain = get_connected_domain(data_matrix, (idx+1,N-1), deepcopy(zeros))
                edge_connect_matrix_list.append(connect_domain)

    total_connect = get_zeros(len(data_matrix))
    for m in edge_connect_matrix_list:
        for row_idx, row in enumerate(m):
            for c_idx, d in enumerate(row):
                total_connect[row_idx][c_idx] += d
    for row_idx, row in enumerate(total_connect):
        for c_idx, d in enumerate(row):
            if d == 0 and data_matrix[row_idx][c_idx]==0:
                data_matrix[row_idx][c_idx] = 1
    return data_matrix


if __name__=="__main__":
    n = sys.stdin.readline().strip()
    n = int(n)
    data_list = []
    for idx in range(n):
        line = sys.stdin.readline().strip()
        line = [int(d) for d in line]
        data_list.append(line)
    result = connected_domain(data_list)
    for l in result:
        print(' '.join([str(_l) for _l in l]))
    

    
